package com.ourpackage.tunestone;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.*;

import com.ourpackage.tunestone.entities.*;
import com.ourpackage.tunestone.parsers.*;

public class MainTest {
	private static List<SiteSource> sources = new ArrayList<SiteSource>();
	private static List<ISiteParser> parsers = new ArrayList<ISiteParser>();

	public static void main(String[] args) {
				
		initSources();		
		initParsers();
		
		for (ISiteParser parser : parsers) {
			System.out.println("!---- Source: " + parser.getSource() + " ----!");
			System.out.println();
			if (parser.isValid()) {
				parser.doParse();
//				for (Object result : parser.getResults()) {
//					System.out.println(result.toString());
//				}
			}
		}
	}

	private static void initParsers() {
		parsers.add(new RollingstoneSiteParser(sources.get(0)));
//		parsers.add(new BillboardSiteParser(sources.get(1)));
		
	}

	private static void initSources() {
		SiteSource rollingStone = new SiteSource();
		rollingStone.setId(0);
		rollingStone.setTitle("RollingStone");
		URL url1 = null;
		try {
			url1 = new URL("http://www.rollingstone.com/music/albumreviews");
		} catch (MalformedURLException e) {
			e.printStackTrace();
		}
		rollingStone.setLink(url1);
		
		SiteSource billboard = new SiteSource();
		billboard.setId(1);
		billboard.setTitle("Billboard");
		URL url2 = null;
		try {
			url2 = new URL("http://www.billboard.com");
		} catch (MalformedURLException e) {
			e.printStackTrace();
		}
		billboard.setLink(url2);
		
		sources.add(rollingStone);
		sources.add(billboard);
	}

}
